﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/BackSite.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
     添加管理员 
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="TablePlaceHolder" runat="server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="TitlePlaceHolder" runat="server">
    <div id="title" style="background-image: url('../../Content/images/toolbar_bg.gif'); background-repeat: repeat-x">
        <span class="font16 fLeft" style="font-size: 26px"><strong>添加管理员</strong></span><span class="fRight mR10 mT08"></span>
    </div>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <style type="text/css">
        .error {
            color: red;
        }

        #Select1 {
            width: 126px;
        }

        #Select2 {
            width: 48px;
        }
        .auto-style1 {
            width: 100%;
        }
        .auto-style2 {
            text-align: center;
        }
        .auto-style3 {
            text-align: right;
        }
        .auto-style4 {
            text-align: left;
        }
    .auto-style5 {
        text-align: right;
        height: 31px;
    }
    .auto-style6 {
        text-align: left;
        height: 31px;
            width: 654px;
        }
    .auto-style7 {
        text-align: right;
        height: 37px;
    }
    .auto-style8 {
        text-align: left;
        height: 37px;
            width: 654px;
        }
    .auto-style9 {
        text-align: right;
        height: 36px;
    }
    .auto-style10 {
        text-align: left;
        height: 36px;
            width: 654px;
        }
    .auto-style11 {
        text-align: right;
        height: 39px;
    }
    .auto-style12 {
        text-align: left;
        height: 39px;
            width: 654px;
        }
    .auto-style13 {
        text-align: right;
        height: 44px;
    }
    .auto-style14 {
        text-align: left;
        height: 44px;
            width: 654px;
        }
    #BtnCancel {
        width: 72px;
    }
    #btnSub {
        width: 68px;
    }
        .auto-style15 {
            text-align: left;
            width: 654px;
        }
    </style>

    <script type="text/javascript">
        $(document).ready(function () {
            $.formValidator.initConfig({ onError: function (msg) { alert(msg); return; } });

            $("#txtUserName").formValidator({ onshow: "请输入姓名", onfocus: "请输入姓名", oncorrect: "该姓名可以注册" }).InputValidator({ min: 2, max: 10, onerror: "你输入的姓名非法,请确认" });

            $("#txtID").formValidator({ onshow: "请输入15或18位的身份证", onfocus: "输入15或18位的身份证", oncorrect: "输入正确" }).FunctionValidator({ fun: isCardID });

            $("#txtEmail").formValidator({ onshow: "请输入邮箱", onfocus: "邮箱至少6个字符,最多100个字符", oncorrect: "恭喜你,你输对了", defaultvalue: "@" }).InputValidator({ min: 6, max: 100, onerror: "你输入的邮箱长度非法,请确认" }).RegexValidator({ regexp: "^([\\w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([\\w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$", onerror: "你输入的邮箱格式不正确" });

            $("#txtPhone").formValidator({ empty: true, onshow: "请输入你的手机号码，可以为空哦", onfocus: "你要是输入了，必须输入正确", oncorrect: "谢谢你的合作", onempty: "" }).InputValidator({ min: 11, max: 11, onerror: "手机号码必须是11位的,请确认" }).RegexValidator({ regexp: "mobile", datatype: "enum", onerror: "你输入的手机号码格式不正确" });;

            jQuery.validator.addMethod("txtUserName", function (value, element) {
                return this.optional(element) || /^[\u0391-\uFFE5\w]+$/.test(value);
            }, "用户名只能包括中文字、英文字母、数字和下划线");

            var ma = $('#form1').validate();

            jQuery.extend(jQuery.validator.messages, {
                required: "必填项",
                remote: "Please fix this field.",
                email: "邮箱格式不正确,请确认",
                url: "URL地址格式错误，请确认",
                date: "日期格式错误，请确认",
                dateISO: "日期格式(ISO)错误，请确认.",
                number: "请输入数字",
                digits: "请输入整数",
                creditcard: "信用卡号码格式错误",
                equalTo: "两次输入不一致",
                accept: "后缀名错误",
                mobile: "手机号码格式错误",
                tel: "电话号码格式错误",
                mobileOrTel: "手机或电话号码格式错误",
                qq: "QQ号码格式错误",
                chinese: "请输入中文",
                idcard: "身份证号码格式错误",
                letter: "请输入字母",
                ip: "IP地址格式错误",
                zipcode: "邮政编码格式错误",
                maxlength: $.validator.format("最多输入 {0} 个字符"),
                minlength: $.validator.format("最少输入 {0} 个字符"),
                rangelength: $.validator.format("字符长度介于 {0} 到 {1} 之间"),
                range: $.validator.format("值大小介于 {0} 到 {1}之间"),
                max: $.validator.format("最大值不超过 {0}"),
                min: $.validator.format("最小值不小于 {0}")
            });

            $("#btnSub").click(function () {
                $.formValidator.initConfig({ onError: function (msg) { alert(msg); return; } });
                var UserIDvalue = $("#txtUserName").val();
                var txtDept = $("#txtDept").val();
                var sexValue = $('#sexSelect option:selected').val();
                var txtID = $("#txtID").val();
                var txtPhone = $("#txtPhone").val();
                var txtAddress = $("#txtAddress").val();
                $.ajax({
                    type: "POST",
                    url: "insertAdmin",
                    data: "txtUserName=" + UserIDvalue + "&&txtDept=" + txtDept + "&&sexValue=" + sexValue + "&&txtID" + txtID + "&&txtPhone" + txtPhone + "&&txtAddress" + txtAddress,
                    success: function (sesponseTest) {
                        alert(sesponseTest);
                    }
                });
            });

            //$('#form1').submit(function () {
            //    $.formValidator.initConfig({ onError: function (msg) { alert(msg); return; } });
            //    var UserIDvalue = $("#txtUserName").val();
            //    var txtDept = $("#txtDept").val();
            //    var sexValue = $('#sexSelect option:selected').val();
            //    var txtID = $("#txtID").val();
            //    var txtPhone = $("#txtPhone").val();
            //    var txtAddress = $("#txtAddress").val();
            //    $.ajax({
            //        type: "POST",
            //        url: "insertAdmin",
            //        data: "txtUserName=" + UserIDvalue + "&&txtDept=" + txtDept + "&&sexValue=" + sexValue + "&&txtID" + txtID + "&&txtPhone" + txtPhone + "&&txtAddress" + txtAddress,
            //        success: function (sesponseTest) {
            //            alert(sesponseTest);
            //        }
            //    });
            //});

        });
    </script>

    &nbsp;<table class="auto-style1">
        <tr>
            <td class="auto-style3"><p style="font-weight: 700">
                管理员姓名：</p>
            </td>
            <td class="auto-style15">
        <input id="txtUserName" type="text" name="txtUserName"  required="required" /></td>
            <td><div id="txtUserNameTip" style="width:250px;"></div></td>
        </tr>
        <tr>
            <td class="auto-style3">
    <p style="font-weight: 700">
        所属部门：</p>
            </td>
            <td class="auto-style15">
                一级部门：<select id="txtDept" name="txtDept">
                    <option>非采油厂</option>
                    <option>采油厂</option>
                </select>&nbsp;&nbsp; 二级部门：<select id="txtDept0" name="txtDept0">
                    <option>第一采气大队</option>
                    <option>第二采气大队</option>
                    <option>第三采气大队</option>
                    <option>第一采油大队</option>
                    <option>第二采油大队</option>
                    <option>第三采油大队</option>
                    <option>第一注水大队</option>
                    <option>第二注水大队</option>
                    <option>第三注水大队</option>
                </select>&nbsp;&nbsp; 三级部门：<select id="txtDept1" name="txtDept1">
                    <option>第一采气小队</option>
                    <option>第二采气小队</option>
                    <option>第三采气小队</option>
                    <option>第一采油小队</option>
                    <option>第二采油小队</option>
                    <option>第三采油小队</option>
                    <option>第一注水小队</option>
                    <option>第二注水小队</option>
                    <option>第三注水小队</option>
                </select></td>
        </tr>
        <tr>
            <td class="auto-style5"><strong>性别：</strong></td>
            <td class="auto-style6">
        <select id="sexSelect" name="sexSelect">
            <option>男</option>
            <option>女</option>
        </select></td>
        </tr>
        <tr>
            <td class="auto-style7"><strong>身份证号：</strong></td>
            <td class="auto-style8">
        <input id="txtID" type="text" name="txtID" /></td>
            <td><div id="txtIDTip" style="width:250px"></div></td>
        </tr>
        <tr>
            <td class="auto-style9"><strong>手机号：</strong></td>
            <td class="auto-style10">
        <input id="txtPhone" type="text" name="txtPhone"/></td>
            <td><div id="txtPhoneTip" style="width:250px"></div></td>
        </tr>
        <tr>
            <td class="auto-style11"><strong>邮箱：</strong></td>
            <td class="auto-style12">
        <input id="txtEmail" type="text" name="txtEmail"/></td>
                  <td><div id="txtEmailTip" style="width:250px"></div></td>

        </tr>
        <tr>
            <td class="auto-style13"><strong>住址：</strong></td>
            <td class="auto-style14">
        <input id="txtAddress" type="text" name="txtAddress" /></td>
        </tr>
        <tr>
            <td class="auto-style3"><input type="submit" id="btnSub" name="btnSub" value="添加" /></td>
            <td class="auto-style15">
    <input id="BtnCancel" type="button" value="取消" onclick="document.getElementById('txtUserName').value = document.getElementById('txtDept').value = document.getElementById('txtID').value = document.getElementById('txtPhone').value = document.getElementById('txtAddress').value = ''"/></td>
        </tr>
    </table>
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="TableHeadPlaceHolder" runat="server">
</asp:Content>
